{ Russian Olympiad. 2 stage.
  Problemset: http://agul-problems1.googlecode.com/svn/trunk/2010-2011/roi/stage2/roi_2stage.pdf
  Problem 3
  Points: 100
}
{$APPTYPE CONSOLE}
var a,b,i,k:longint; steps,cur,max,j,t,current:int64; count:array[-1..1000001] of int64; step:array[1..1000001] of longint;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(a,b);
fillchar(count,sizeof(count),0);
max:=0;
for i := a to b do begin
  if count[i]=0 then begin
    cur:=i;
    current:=0;
    steps:=1;
    while cur>1 do begin
      inc(steps);
      inc(current);
      if odd(cur) then cur:=3*cur+1 else cur:=cur div 2;
      if cur<=b then begin
        step[current]:=cur;
        if count[cur]<>0 then begin
          inc(steps,count[cur]-1);
          cur:=1;
        end;
      end else step[current]:=-1;
    end;
    if steps>max then max:=steps;
    count[i]:=steps;
    j:=0;
    while j<current-1 do begin
      inc(j);
      if step[j]<>-1 then count[step[j]]:=steps-j;
    end;
  end;
end;
writeln(max);
close(input);
close(output);
end.
